<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.math.GammaFunction</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.math.GammaFunction");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327">tango.math.GammaFunction</a></h1>
                
<font color="black">Implementation of the gamma and beta functions, and their integrals.</font><br><br>
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Authors:</b><br>
Stephen L. Moshier &#40;original C code&#41;. Conversion to D by Don Clugston<br><br>
<script>explorer.outline.incSymbolLevel();</script>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L35">MAXGAMMA</a></span>
<script>explorer.outline.addDecl('MAXGAMMA');</script>; [const]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The maximum value of x for which gamma&#40;x&#41; &lt; real.infinity.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L134">sgnGamma</a></span>
<script>explorer.outline.addDecl('sgnGamma');</script>(real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The sign of &#915;&#40;x&#41;.</font><br><br>
<font color="black">Returns -1 if &#915;&#40;x&#41; &lt; 0,  +1 if &#915;&#40;x&#41; &gt; 0,
 <font color="red">NAN</font> if sign is indeterminate.
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L182">gamma</a></span>
<script>explorer.outline.addDecl('gamma');</script>(real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">The Gamma function, &#915;&#40;x&#41;</font><br><br>
<font color="black">&#915;&#40;x&#41; is a generalisation of the factorial function
  to real and complex numbers.
  Like x!, &#915;&#40;x+1&#41; = x*&#915;&#40;x&#41;.<br><br>  Mathematically, if z.re &gt; 0 then
   &#915;&#40;z&#41; = <big>&#8747;<sub><small>0</small></sub><sup>&infin;</sup></big> t<sup>z-1</sup>e<sup>-t</sup> dt<br><br>  <table border=1 cellpadding=4 cellspacing=0>
      <caption>Special Values</caption>
      
    <tr><th>x</th> <th>&#915;(x) </th></tr>
    <tr><td><font color="red">NAN</font></td> <td><font color="red">NAN</font>      </td></tr>
    <tr><td>&plusmn;0.0</td> <td>&plusmn;&infin;</td></tr>
    <tr><td>integer > 0</td> <td>(x-1)!      </td></tr>
    <tr><td>integer < 0</td> <td><font color="red">NAN</font>      </td></tr>
    <tr><td>+&infin;</td> <td>+&infin;    </td></tr>
    <tr><td>-&infin;</td> <td><font color="red">NAN</font>      </td></tr>
  </table>
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L317">logGamma</a></span>
<script>explorer.outline.addDecl('logGamma');</script>(real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Natural logarithm of gamma function.</font><br><br>
<font color="black">Returns the base e &#40;2.718...&#41; logarithm of the absolute
 value of the gamma function of the argument.<br><br> For reals, logGamma is equivalent to log&#40;fabs&#40;gamma&#40;x&#41;&#41;&#41;.<br><br>  <table border=1 cellpadding=4 cellspacing=0>
      <caption>Special Values</caption>
      
    <tr><th>x</th> <th>logGamma(x)   </th></tr>
    <tr><td><font color="red">NAN</font></td> <td><font color="red">NAN</font>      </td></tr>
    <tr><td>integer <= 0</td> <td>+&infin;    </td></tr>
    <tr><td>&plusmn;&infin;</td> <td>+&infin;    </td></tr>
  </table>
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L457">beta</a></span>
<script>explorer.outline.addDecl('beta');</script>(real <span class="funcparam">x</span>, real <span class="funcparam">y</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Beta function</font><br><br>
<font color="black">The beta function is defined as<br><br> beta&#40;x, y&#41; = &#40;&Gamma;&#40;x&#41; &Gamma;&#40;y&#41;&#41;/&Gamma;&#40;x + y&#41;
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L491">betaIncomplete</a></span>
<script>explorer.outline.addDecl('betaIncomplete');</script>(real <span class="funcparam">aa</span>, real <span class="funcparam">bb</span>, real <span class="funcparam">xx</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Incomplete beta integral</font><br><br>
<font color="black">Returns incomplete beta integral of the arguments, evaluated
 from zero to x. The regularized incomplete beta function is defined as<br><br> betaIncomplete&#40;a, b, x&#41; = &Gamma;&#40;a+b&#41;/&#40;&Gamma;&#40;a&#41; &Gamma;&#40;b&#41;&#41; *
 <big>&#8747;<sub><small>0</small></sub><sup>x</sup></big> t<sup>a-1</sup>(1-t)<sup>b-1</sup> dt<br><br> and is the same as the the cumulative distribution function.<br><br> The domain of definition is 0 &lt;= x &lt;= 1.  In this
 implementation a and b are restricted to positive values.
 The integral from x to 1 may be obtained by the symmetry
 relation<br><br>    betaIncompleteCompl&#40;a, b, x &#41;  =  betaIncomplete&#40; b, a, 1-x &#41;<br><br> The integral is evaluated by a continued fraction expansion
 or, when b*x is small, by a power series.
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L591">betaIncompleteInv</a></span>
<script>explorer.outline.addDecl('betaIncompleteInv');</script>(real <span class="funcparam">aa</span>, real <span class="funcparam">bb</span>, real <span class="funcparam">yy0</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Inverse of incomplete beta integral</font><br><br>
<font color="black">Given y, the function finds x such that<br><br>  betaIncomplete&#40;a, b, x&#41; == y<br><br>  Newton iterations or interval halving is used.
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L1103">gammaIncomplete</a></span>
<script>explorer.outline.addDecl('gammaIncomplete');</script>(real <span class="funcparam">a</span>, real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L1146">gammaIncompleteCompl</a></span>
<script>explorer.outline.addDecl('gammaIncompleteCompl');</script>(real <span class="funcparam">a</span>, real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Incomplete gamma integral and its complement</font><br><br>
<font color="black">These functions are defined by<br><br>   gammaIncomplete = &#40; <big>&#8747;<sub><small>0</small></sub><sup>x</sup></big> e<sup>-t</sup> t<sup>a-1</sup> dt &#41;/ &#915;&#40;a&#41;<br><br>  gammaIncompleteCompl&#40;a,x&#41;   =   1 - gammaIncomplete&#40;a,x&#41;
 = &#40;<big>&#8747;<sub><small>x</small></sub><sup>&infin;</sup></big> e<sup>-t</sup> t<sup>a-1</sup> dt &#41;/ &#915;&#40;a&#41;<br><br> In this implementation both arguments must be positive.
 The integral is evaluated by either a power series or
 continued fraction expansion, depending on the relative
 values of a and x.
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L1226">gammaIncompleteComplInv</a></span>
<script>explorer.outline.addDecl('gammaIncompleteComplInv');</script>(real <span class="funcparam">a</span>, real <span class="funcparam">p</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Inverse of complemented incomplete gamma integral</font><br><br>
<font color="black">Given a and y, the function finds x such that<br><br>  gammaIncompleteCompl&#40; a, x &#41; = p.<br><br> Starting with the approximate value x = a t<sup>3</sup>, where
 t = 1 - d - normalDistributionInv&#40;p&#41; sqrt&#40;d&#41;,
 and d = 1/9a,
 the routine performs up to 10 Newton iterations to find the
 root of incompleteGammaCompl&#40;a,x&#41; - p = 0.
 </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>real <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/math/GammaFunction.d?rev=3327#L1368">digamma</a></span>
<script>explorer.outline.addDecl('digamma');</script>(real <span class="funcparam">x</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Digamma function</font><br><br>
<font color="black">The digamma function is the logarithmic derivative of the gamma function.<br><br>  digamma&#40;x&#41; = d/dx logGamma&#40;x&#41;<br><br></font><br><br></dd></dl>
<script>explorer.outline.decSymbolLevel();</script></td></tr>
                <tr><td id="docfooter">
                        Based on the CEPHES math library, which is
            Copyright (C) 1994 Stephen L. Moshier (moshier@world.std.com). :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Tue Mar  4 22:45:34 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>